﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Dynamic;

namespace DynamicFunInStaticLanguages
{
    class Program
    {
        static void Main(string[] args)
        {
            DoSomethingWithDynamic();
            DoSomethingWithExpandoObject();
            DoSomethingWithFunkyXml();
        }

        private static void DoSomethingWithFunkyXml()
        {
            dynamic reader = DynamicXmlReader.Parse("<foo><bar zing=\"9001\"></bar></foo>");
            Console.WriteLine(reader.bar.zing);
        }

        private static void DoSomethingWithExpandoObject()
        {
            dynamic bag = new ExpandoObject();
            bag.Name = "Bubba";
            bag.Height = 4.5;

            Console.WriteLine(bag.Name);
            Console.WriteLine(bag.Height);
        }

        private static void DoSomethingWithDynamic()
        {
            dynamic sayIt = new SayCode();

            sayIt.SaySomethingCool();
            sayIt.SayEricIsTotallyRad();

            sayIt.HailYourCreator();
        }
    }
}
